import requests


class LoginAPI:
    @classmethod
    def get_image_code(cls, session):
        session.get("http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify")

    @classmethod
    def tpshop_login_api(cls, session, login_body):
        login_url = "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=do_login"
        login_header = {"Content-Type": "application/x-www-form-urlencoded"}
        login_resp = session.post(url=login_url, headers=login_header, data=login_body)
        return login_resp

    @classmethod
    def get_requests_image_code(cls,session):
        session.get("http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.8307250617074824")

    @classmethod
    def tpshop_requests_api(cls,session,register_body):
        register_url = "http://hmshop-test.itheima.net/Home/User/reg.html"
        register_header = {"Content-Type": "application/x-www-form-urlencoded"}
        register_resp = session.post(url=register_url, headers=register_header, data=register_body)
        return register_resp